#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
	int n,x,y,sum=0;
	cin>>n>>x>>y;
	vector<int>v(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
		sum+=v[i];
	}
	sort(v.begin()+1,v.end());
	int ans=0,l=2,r=n;
	for(int i=1;i<=n;i++)
	{
		if(i==l)l++;
		while(l<=r&&v[i]+v[l]<sum-y)l++;
		if(l>n)l--;
		while(l>i&&v[i]+v[l]>=sum-y)l--;
		if(l<=r)l++;
		else continue;
		while(l<=r&&v[i]+v[r]>sum-x)r--;
		while(r<=n&&v[i]+v[r]<=sum-x)r++;
		if(l<=r)r--;
		else continue;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
}
signed main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	int T=1;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}